<!DOCTYPE html>
<html lang="zh_CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- <script src="./1.js"></script> -->
  <script>

    var p1 = new Promise(function (resolve, reject) {
      setTimeout(resolve, 900, 'P1');
    });
    var p2 = new Promise(function (resolve, reject) {
      setTimeout(resolve, 600, 'P2');
    });
    // 同时执行p1和p2，并在它们都完成后执行then:

    Promise.all([p1, p2]).then(function (results) {
      console.log(results); // 获得一个Array: ['P1', 'P2']
    });
    let arr = [p1, p2]
    // for (let index = 0; index < arr.length; index++) {
    //   arr[index].then(res=>{
    //     console.log(res);
    //   })
    // }
    async function yyy() {
      arr.forEach(async function (item) {
        await item.then((res) => {
          console.log(res);
        })
      });
    }
    yyy()


  </script>
</head>

<body>
</body>

</html>